﻿using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using VS.Infrastructure;
using VS.MainModule.Views;

namespace VS.MainModule
{
    public class Module : IModule
    {
        [Dependency]
        public IRegionManager RegionManager { get; set; }

        [Dependency]
        public IUnityContainer Container { get; set; }

        public void Initialize()
        {
            Container.RegisterInstance<AdminViewModel>(new AdminViewModel(), new ContainerControlledLifetimeManager());
            Container.RegisterInstance<LoginViewModel>(new LoginViewModel(), new ContainerControlledLifetimeManager());
            Container.RegisterInstance<ArticleViewModel>(new ArticleViewModel(), new ContainerControlledLifetimeManager());

            Container.RegisterType<object, MainView>("main");
            Container.RegisterType<object, ArticleView>("article");
            Container.RegisterType<object, LoginView>("login");
            Container.RegisterType<object, AdminView>("admin");

            RegionManager.RegisterViewWithRegion(RegionNames.ToolbarRegion, typeof(ToolbarView));
            
        }
    }
}
